package com.cooba.broadCastReceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.Toast;

import com.cooba.utils.CommonUtil;


/**
 * Created by Administrator on 2016/6/3.
 */
public class AppReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        if (TextUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_ADDED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
           // Toast.makeText(context, "安装成功" + packageName, Toast.LENGTH_LONG).show();
            String gameId=CommonUtil.getGameId(packageName);
            if (!TextUtils.isEmpty(gameId))
            CommonUtil.getVantager(context,gameId);

        } else if (TextUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_REPLACED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
            //Toast.makeText(context, "替换成功" + packageName, Toast.LENGTH_LONG).show();

        } else if (TextUtils.equals(intent.getAction(), Intent.ACTION_PACKAGE_REMOVED)) {
            String packageName = intent.getData().getSchemeSpecificPart();
            //Toast.makeText(context, "卸载成功" + packageName, Toast.LENGTH_LONG).show();
        }
    }

}
